<template>
	<view class="bg" style="position: relative;">
		<view class="padding-lr text-center padding-tb" >
			<view class=" base-font-40 text-bold base-bg-1 padding-tb-sm">{{title}}</view>
			<view class=" text-999 padding-bottom-sm"><text class="cuIcon-attention"></text><text class="margin-left-xs">{{num}}</text><text class="padding-left" v-if="createTimeStr">{{createTimeStr.substr(0,16)}}</text></view>
			<view class="backHome" @click="backHomeBtn">
				<view class="text-center">
					<view>
						<text class="cuIcon-homefill"></text>
					</view>
					<view class="base-font-24">首页</view>
				</view>
			</view>
		</view>
   
	<!-- <view class="newsImg" v-if="$util.isNotBlank(neswImg)"><image :src="neswImg" mode="aspectFill"></image></view> -->
	<view class=" padding-lr padding-top-sm" style="line-height:1.9;border-top:1rpx solid #eee;"><u-parse  :content="content"></u-parse></view>
	</view>
</template>

<script>
	import uParse from '@/components/feng-parse/parse.vue'
  import api from '@/utils/api.js';
  import siteApi from '@/utils/siteApi.js';
	export default {
		components: {uParse},
		data() {
			return {
				id:'',
				title:'',
			content:'',
			num:0,
			createTimeStr:'',
			neswImg:''
			}
		},
		onShareTimeline: function(res) {
			return api.getShare(res,'','/pages/news/desc?id='+this.id);
		},
		onShareAppMessage: function(res) {
				return api.getShare(res,'','/pages/news/desc?id='+this.id);
		},
		onShow(options){
		  let pages = getCurrentPages();
		  let currPage = pages[pages.length-1];
		  this.initData();
		},
		onLoad(option){
			var id=api.acceptShare(2,option);
			if(this.$util.isNotEmpty(id)){
				this.id=id;
				//this.initData();
			}else{
				uni.showToast({
				  title:'id不能为空',
				  duration:200
				})
				uni.navigateBack();
			}
		},
		methods: {
			backHomeBtn(){
				uni.navigateTo({
					url:'/pages/index/index'
				})
			},
			initData:function(){
				let _self=this;
				siteApi.getWxNoticeById({id:this.id}).then(res=>{
					 _self.title=res.data.name;
				    _self.content=res.data.description;
					_self.num=res.data.readNum;
					_self.neswImg=res.data.image
					_self.createTimeStr=res.data.createTimeStr
					// _self.time=_self.$util.formatDate(res.data.createTime,'yyyy-MM-dd HH:mm:ss');
				});
			},
		}
	}
</script>

<style>
  page,.bg{background:#ffffff;}
</style>
<style lang="scss" scoped>
	@import "../../static/css/variables.scss";
	.newsImg{width:100%;height:300rpx;margin:20rpx auto;
	image{width:100%;height:300rpx;}
	}
	.backHome{position: fixed;top:45vh;z-index:99999;left:0;background: #ffffff;box-shadow:0 0 20rpx #ddd;border-radius:0 20rpx 20rpx 0;padding:20rpx;}
</style>
